#include "serverPool.h"

int serverPoolInit(serverPool_t *pserver,int workerNum){
    tidArrInit(&pserver->tidArr,workerNum);
    taskQueueInit(&pserver->que);
    pthread_mutex_init(&pserver->mutex,NULL);
    pthread_cond_init(&pserver->cond,NULL);
    pserver->exitFlag=0;
    return 0;
}
bool isTruePath(path_t path,signalsend_t signal){
    path_t tmpPath;
    
    initPath(&tmpPath);
    strcpy(tmpPath.absolutePath,path.absolutePath);
    strcpy(tmpPath.initialPath,path.initialPath);
    strcpy(tmpPath.pwd,path.pwd);
    sNode_t *p = path.pathStack.bottom;
    while(p != NULL)
    {
        pathStackPush(&tmpPath.pathStack,p->pathname);
        p = p->next;
    }
    

    cd(&tmpPath,signal.pathname,signal.size);
    int ret=access(tmpPath.absolutePath,F_OK);
    if(ret!=0){
        return false;
    }else{
        struct stat stat_buf;
        stat(tmpPath.absolutePath,&stat_buf);
        if((stat_buf.st_mode&S_IFMT) == S_IFDIR){
            return true;
        }else{
            return false;
        }
    }
}
